import { Module } from 'vuex'

interface Space {
  type: 'user' | 'enterprise';
  name: string;
  ownId: number;
}

class AppState {
  spaces: Space[] = [];

  currentSpace: Space | null = null;

  properties: any = null

  permGroups: any[] = []
}

const app: Module<AppState, unknown> = {
  namespaced: true,
  state: new AppState(),
  mutations: {
    setSpaces (state: AppState, spaces: any[] = []) {
      state.spaces = spaces
    },
    setCurrentSpace (state: AppState, space: any) {
      state.currentSpace = space || null
    },
    setProperties (state: AppState, properties: any) {
      state.properties = properties || null
    },
    setPermGroups (state: AppState, groups: any[]) {
      state.permGroups = groups
    }
  },
  getters: {},
  actions: {
  }
}

export default app
